//find_if()函数的模拟实现
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>//STL算法函数

//仿函数
template<typename T>
class person{
public:
    person(T val):val2(val){}
    T val2;
    bool operator()(T val1){
        return val1==val2;
    }
};
template<typename T1,typename T2>
T1 findif(T1 frist,T1 last,T2 pfun){
    for(T1 it=frist;it!=last;it++){
        if(pfun(*it)==true){
            return it;
        }
    }
    return last;
}
using namespace std;
int main()
{
    vector<int> a {1,2,3,4,5,6,7,8};
    list<string> e {"1","2","2","3"};
    auto d=findif(a.begin(),a.end(),person<int>(10));
    auto f=find_if(e.begin(),e.end(),person<string>("12"));
    if(d==a.end()){
        cout<<"查找失败"<<endl;
    }
    else{
        cout<<"查找成功"<<endl;
    }
    return 0;
}